﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using sharp_net.Mvc.HelpPage;

namespace danreng.Api.Controllers {
    public class HelpController : Controller {

        public HelpController()
            : this(GlobalConfiguration.Configuration) {
        }
        public HelpController(HttpConfiguration config) {
            Configuration = config;
        }
        public HttpConfiguration Configuration { get; private set; }

        public ActionResult Index() {
            return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
        }

        public ActionResult Api(string apiId) {
            if (!String.IsNullOrEmpty(apiId)) {
                HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId);
                if (apiModel != null) {
                    return View(apiModel);
                }
            }
            return View("Error");
        }

    }
}
